package cn.itdlz.action;

import java.io.IOException;
import java.util.List;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

import cn.itdlz.domain.Comic;
import cn.itdlz.domain.ComicBc;
import cn.itdlz.service.ComicBcService;
import cn.itdlz.service.ComicService;
import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;

public class ComicBcAction extends ActionSupport implements ModelDriven<ComicBc>  {
	private ComicBc comicBc=new ComicBc();
	@Override
	public ComicBc getModel() {
		// TODO Auto-generated method stub
		return comicBc;
	}
	private ComicBcService comicBcService;
	
	public void setComicBcService(ComicBcService comicBcService) {
		this.comicBcService = comicBcService;
	}

	public String findAll() throws IOException {
		List<ComicBc> list = comicBcService.findAll(comicBc.getComic_id().getComic_id());
		JsonConfig jc=new JsonConfig();
		jc.setExcludes(new String[] {"comic_id"});
		JSONArray jsonArray=JSONArray.fromObject(list,jc);
		ServletActionContext.getResponse().setContentType("text/html;charset=UTF-8");
		ServletActionContext.getResponse().getWriter().println(jsonArray.toString());
		return NONE;
	}

}
